package com.jtny.nytb.config.dataalgorithm.service;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.jtny.component.entity.PageData;
import com.jtny.component.exception.ServiceException;
import com.jtny.nytb.equipment.dto.dataalgorithm.DataAlgorithmDTO;
import com.jtny.nytb.equipment.dto.dataalgorithm.DataAlgorithmPageQueryParamDTO;
import com.jtny.nytb.equipment.dto.dataalgorithm.DataAlgorithmScriptAndFormulaDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 数据算法Service接口
 * @package com.jtny.nytb.config.dataalgorithm..service
 * @fileName DataAlgorithmService.java
 * @author 智慧能源中心 - 夏燕强
 * @createTime 2023年9月02日 15:18
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Api(value = "数据算法Api接口", tags = "数据算法Api接口")
@ApiSort(102022)
public interface DataAlgorithmService {

    /**
     * 分页查询数据算法信息
     * @param dataAlgorithmPageQueryParamDTO 分页查询参数DTO对象
     * @return 返回数据算法信息分页查询结果PageData对象
     */
    @ApiOperation("分页查询数据算法信息")
    @ApiImplicitParam(name = "dataAlgorithmPageQueryParamDTO", value = "分页查询参数DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 1)
    @PostMapping("/queryPage")
    @ResponseBody
    PageData<DataAlgorithmDTO> queryPage(@RequestBody DataAlgorithmPageQueryParamDTO dataAlgorithmPageQueryParamDTO) throws ServiceException;


    /**
     * 保存数据算法信息
     * @param algorithmScriptAndFormulaDTO 数据算法基本信息与算法配置DTO对象
     * @return 返回保存后的数据算法基本信息与算法配置DTO对象
     * @throws ServiceException 抛出异常
     */
    @ApiOperation("保存数据算法信息")
    @ApiImplicitParam(name = "algorithmScriptAndFormulaDTO", value = "数据算法信息DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 2)
    @PostMapping("/save")
    @ResponseBody
    DataAlgorithmScriptAndFormulaDTO save(@RequestBody DataAlgorithmScriptAndFormulaDTO algorithmScriptAndFormulaDTO) throws ServiceException;

    /**
     * 通过主键id获取数据算法信息
     * @param id 主键id
     * @return 返回数据算法信息
     */
    @ApiOperation("通过主键id获取数据算法信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 3)
    @RequestMapping("/getById/{id}")
    @ResponseBody
    DataAlgorithmDTO getById(@PathVariable("id") Long id);

    /**
     * 修改数据算法信息
     * @param dataAlgorithmDTO 数据算法信息DTO对象
     * @throws ServiceException 抛出异常
     */
    @ApiOperation("修改数据算法信息")
    @ApiImplicitParam(name = "dataAlgorithmDTO", value = "数据算法信息DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 4)
    @PutMapping("/update")
    @ResponseBody
    void update(@RequestBody DataAlgorithmDTO dataAlgorithmDTO) throws ServiceException;

    /**
     * 通过算法id获取数据算法基本信息与数据算法配置信息
     * @param id 算法id
     * @return 返回数据算法信息与数据算法配置信息
     */
    @ApiOperation("通过算法id获取数据算法信息")
    @ApiImplicitParam(name = "id", value = "算法id", required = true, paramType = "path")
    @ApiOperationSupport(order = 5)
    @RequestMapping("/getFormulaOrScriptById/{id}")
    @ResponseBody
    DataAlgorithmScriptAndFormulaDTO getFormulaOrScriptById(@PathVariable("id") Long id);

    /**
     * 通过算法名字获取数据算法信息
     *
     * @param name 算法名字
     * @return 返回数据算法信息
     */
    @ApiOperation("通过算法名字获取数据算法信息")
    @ApiImplicitParam(name = "name", value = "算法名字", required = true, paramType = "path")
    @ApiOperationSupport(order = 3)
    @GetMapping("/getByName/{name}")
    @ResponseBody
    DataAlgorithmScriptAndFormulaDTO getAlgorithmByName(@PathVariable("name") String name);

    /**
     * 按名称列表映射算法
     *
     * @param nameList 名称列表
     * @return {@link Map}<{@link String}, {@link DataAlgorithmScriptAndFormulaDTO}>
     */
    @ApiOperation("按名称列表映射算法")
    @ApiImplicitParam(name = "nameList", value = "名称列表", required = true, paramType = "query")
    @ApiOperationSupport(order = 7)
    @PostMapping("/mapAlgorithmByNameList")
    @ResponseBody
    Map<String, DataAlgorithmScriptAndFormulaDTO> mapAlgorithmByNameList(@RequestBody List<String> nameList);

    /**
     * 修改数据算法基本信息与算法配置信息
     * @param scriptAndFormulaDTO 数据算法信息DTO对象
     * @throws ServiceException 抛出异常
     */
    @ApiOperation("修改数据算法信息")
    @ApiImplicitParam(name = "scriptAndFormulaDTO", value = "算法基本信息与算法配置信息DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 6)
    @PostMapping("/updateAlgorithmScriptOrFormula")
    @ResponseBody
    void updateAlgorithmScriptOrFormula(@RequestBody DataAlgorithmScriptAndFormulaDTO scriptAndFormulaDTO) throws ServiceException;

    /**
     * 通过算法id删除关联的算法参数配置信息
     * @param algorithmId 算法id
     * @return
     */
    @ApiOperation("通过算法id删除关联的算法参数配置信息")
    @ApiImplicitParam(name = "algorithmId", value = "算法id", required = true, paramType = "query")
    @ApiOperationSupport(order = 5)
    @PostMapping("/deleteFormulaOrScriptByAlgorithmId")
    @ResponseBody
    void deleteFormulaOrScriptByAlgorithmId(@RequestBody Long algorithmId);

    /**
     * 通过算法名字查询是否存在
     *
     * @param nameList 名称列表
     * @return {@link List}<{@link String}>
     */
    @ApiOperation("通过算法名字查询是否存在")
    @ApiImplicitParam(name = "nameList", value = "算法名字列表", required = true, paramType = "query")
    @ApiOperationSupport(order = 6)
    @PostMapping("/existDataAlgorithmByName")
    @ResponseBody
    List<String> existDataAlgorithmByName(@RequestBody List<String> nameList);

    /**
     * 保存批次
     *
     * @param toSaveList 保存列表
     * @return {@link Boolean}
     */
    @ApiOperation("批量保存数据算法信息")
    @ApiImplicitParam(name = "toSaveList", value = "数据算法信息DTO对象列表", required = true, paramType = "query")
    @ApiOperationSupport(order = 7)
    @PostMapping("/saveBatch")
    @ResponseBody
    Boolean saveBatch(@RequestBody List<DataAlgorithmScriptAndFormulaDTO> toSaveList);
}
